﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class DeviceInspectionsMapping : IEntityTypeConfiguration<DeviceInspections>
    {
        public void Configure(EntityTypeBuilder<DeviceInspections> builder)
        {
            builder.ToTable("DeviceInspections");
            builder.HasKey(di => di.DeviceInspectionId);
            builder.Property(di => di.DeviceInspectionId)
                .HasComment("设备巡检主键，自动编号");

            builder.Property(di => di.DeviceId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("巡检设备，外键（Devices）");

            builder.Property(di => di.CurrentDeviceStatus)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(1)
                .HasComment("设备状态（1使用中，2维修中，3其他），默认值1");

            builder.Property(di => di.InspectorId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("巡检人员，外键（Users）");

            builder.Property(di => di.InspectionTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasComment("巡检日期");

            builder.Property(di => di.Remark)
                .HasColumnType("varchar(150)")
                .HasComment("备注");

            builder.Property(di => di.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(di => di.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(di => di.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(di => di.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(di => di.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
